﻿using System;
using System.Windows;

using Microsoft.WindowsAPICodePack.Dialogs;

namespace SlideShowDFG2
{
    /// <summary>
    /// Interaction logic for SettingsWindow.xaml
    /// </summary>
    public partial class SettingsWindow : Window
    {
        public SettingsWindow()
        {
            InitializeComponent();
        }

        private void btnFFmpegBroswe_Click(object sender, RoutedEventArgs e)
        {
            CommonOpenFileDialog dialog = new CommonOpenFileDialog();
            dialog.Filters.Add(new CommonFileDialogFilter("Executable Files", "*.exe"));
            dialog.Filters.Add(new CommonFileDialogFilter("All Files", "*.*"));
            dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            dialog.Multiselect = false;
            dialog.ShowPlacesList = true;
            dialog.Title = "FFmpeg Location";
            if (dialog.ShowDialog() == CommonFileDialogResult.OK)
            {
                RegistryHelper registry = (RegistryHelper)base.DataContext;
                registry.FFmpegExe = dialog.FileName;
                base.DataContext = registry;
            }
            dialog.Dispose();
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            base.DialogResult = true;
            base.Close();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            base.DataContext = new RegistryHelper();
        }
    }
}
